<?php
namespace Mob \ Model;

use Think \ Model;
use Think \ Hook;
/**招聘签到模型
 * Class InfoModel
 */

require_once ('./Application/Mob/Common/function.php');

class JobsSignModel extends Model {

	 protected $tableName = 'jobs_step_signrecored';

	public function creatorSignRecord($jobsserialno,$currentStep,$signUid,$signLongitude,$signLatitude,$signStatus,$industry,$enterpriseId,$contents)
	{
    $data['jobsserialno']=$jobsserialno;
    $data['currentStep']=$currentStep;
    $data['signUid']=$signUid;
    $data['signTime']=time();
    $data['signLongitude']=$signLongitude;
    $data['signLatitude']=$signLatitude;
    $data['signStatus']=$signStatus;
    $data['contents']=$contents;
    $data['industry']=$industry;
    $data['enterpriseId']=$enterpriseId;
    $data['signserialno']=getSerialno();
    $this->add($data);




	}





	public function is_AlreadySign($jobsserialno,$currentStep,$signUid)
	{
	$where['jobsserialno']=$jobsserialno;
	$where['currentStep']=$currentStep;
	$where['signStatus']=1;
	$where['signUid']=$signUid;

	//$where = array('jobsserialno'=>$jobsserialno,'stepSerialno'=>$stepSerialno,'currentStep'=>$currentStep,'signStatus'=>1,'signUid'=>$signUid);
	return $this->where($where)->field('jobsserialno,signTime,signLongitude,signLatitude,currentStep,contents,enterpriseId,industry,commentNum')->find();


	}
	public function get_AlreadySignNum($jobsserialno,$currentStep)
	{
    $where = array('jobsserialno'=>$jobsserialno,'currentStep'=>$currentStep,'signStatus'=>1);
    return $this->where($where)->count();

	}
    public function get_personSignRecord($uid,$setp,$day)
    {
     $day = empty($day)?strtotime(date('Y-m-d',time()))-86400*90:strtotime($day);
      $jobs = new \ Think \ Model();
     return $jobs->query("select s.jobsserialno,s.currentStep,s.signUid,s.signTime,s.signLongitude,s.signLatitude,s.contents,s.enterpriseId,s.commentNum,s.signserialno,e.name as enterpriseName  " .
      		"from ocenter_jobs_step_signrecored s,ocenter_enterprise e where s.signTime >= $day and s.signUid = $uid and s.currentStep = $setp and s.enterpriseId = e.Id");
    // $where = array('signTime'=>array('egt',$day),'signUid'=>$uid,'currentStep'=>$setp);
    // return $this->where($where)->field('jobsserialno,signTime,signLongitude,signLatitude,currentStep,contents,enterpriseId,industry,commentNum')->select();


    }
    public function get_SignDetails($signSerialno)
    {
    $where = array('signserialno'=>$signSerialno,'signStatus'=>1);
    return $this->where($where)->field('jobsserialno,signTime,signLongitude,signLatitude,currentStep,contents,enterpriseId,industry,commentNum,signserialno')->find();

    }
    public function update_CommentNum($signSerialno)
    {
    $this->where(array('signserialno'=>$signSerialno,'signStatus'=>1))->setInc('commentNum');



    }

























}